package backgammon;

import java.awt.Color;
import java.awt.Graphics;

/**
 * <p>Represents a position on the board that can contain pieces.</p>
 * @author Jacob Kwitkoski
 * @version 1.0
 */
public class BoardPosition extends Position{
    /**
     * <p>Creates a position.</p>
     * @param positionColor the color of the position on the board
     */
    public BoardPosition(final Color newColor,
                         final int   index) {
        super(newColor, index);
    }

    @Override
    public void drawPieces(Graphics g) {
        int x = drawAtX + 4;
        if(arrayIndex > 13) {
            int y = 0;
            for (Piece piece : pieces) {
                g.setColor(piece.getColor());
                g.fillOval(x, y, 42, 42);
                y += 43;
            }
        }
        else {
            int y = 457;
            for (Piece piece : pieces) {
                g.setColor(piece.getColor());
                g.fillOval(x, y, 42, 42);
                y -= 43;
            }
        }
    }
}
